package com.yangit.temp.common.entity.result;


@SuppressWarnings({ "rawtypes", "unchecked" })
public class TradeResult<T> extends JsonResult<T> {
	
	/**
	 * --序列号
	 */
	public static final long serialVersionUID = 1L;
	
	
	
	/**
	 * -业务结果	是
	 * -SUCCESS	SUCCESS/FAIL
	 * 
	 */
	private Code resultCode; 
	
	
	
	/**
	 * -错误代码		 	
	 * -当result_code为FAIL时返回错误代码，详细参见下文错误列表
	 */
	private String errCode;
	
	
	
	/**
	 * -错误代码描述	
	 */
	private String errCodeDes;
	
	
	
	/**
	 * -业务结果
	 */
	private T data;
	
	
	
	public TradeResult() {
		this.resultCode = Code.SUCCESS ;
		this.errCode = "OK" ;
	}
	
	
	
	public TradeResult(String errCode ,String errCodeDes) {
		this.resultCode = Code.SUCCESS ;
		this.errCode = errCode ;
		this.errCodeDes = errCodeDes ;
	}
	
	
	
	public TradeResult(T data) {
		this.resultCode = Code.SUCCESS ;
		this.errCode = "OK" ;
		this.data = data;
	}

	
	
	public Code getResultCode() {
		return resultCode;
	}



	public void setResultCode(Code resultCode) {
		this.resultCode = resultCode;
	}



	public String getErrCode() {
		return errCode;
	}



	public void setErrCode(String errCode) {
		this.errCode = errCode;
	}



	public String getErrCodeDes() {
		return errCodeDes;
	}



	public void setErrCodeDes(String errCodeDes) {
		this.errCodeDes = errCodeDes;
	}



	public T getData() {
		return data;
	}



	public void setData(T data) {
		this.data = data;
	}


	
	public static TradeResult.Builder builder(){
		return new TradeResult.Builder();
	}
	

	public static class Builder<T>{
		
		/**
		 * -业务结果	是
		 * -SUCCESS	SUCCESS/FAIL
		 * 
		 */
		private Code resultCode; 
		
		
		
		/**
		 * -错误代码		 	
		 * -当result_code为FAIL时返回错误代码，详细参见下文错误列表
		 */
		private String errCode;
		
		
		
		/**
		 * -错误代码描述	
		 */
		private String errCodeDes;
		
		
		
		/**
		 * -业务结果
		 */
		private T data;



		public Builder<T> setResultCode(Code resultCode) {
			this.resultCode = resultCode;
			return this;
		}



		public Builder<T> setErrCode(String errCode) {
			this.errCode = errCode;
			return this;
		}



		public Builder<T> setErrCodeDes(String errCodeDes) {
			this.errCodeDes = errCodeDes;
			return this;
		}



		public Builder<T> setData(T data) {
			this.data = data;
			return this;
		}
		
		
		
		public TradeResult<Builder<T>> build() {
			return new TradeResult<Builder<T>>(this);
		}



		@Override
		public String toString() {
			return "TradeResult.Builder [resultCode=" + resultCode + ", errCode=" + errCode + ", errCodeDes=" + errCodeDes
					+ ", data=" + data + "]";
		}
		
		
	}
	
	
	
	@Override
	public String toString() {
		return "TradeResult [resultCode=" + resultCode + ", errCode=" + errCode + ", errCodeDes=" + errCodeDes
				+ ", data=" + data + ", returnCode=" + returnCode + ", returnMsg=" + returnMsg + "]";
	}


	public static void main(String[] args) {
		TradeResult tr = TradeResult.builder().setData("fjskalf ").build();

		System.out.println(tr.getData());
	}
}
